package dept.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import member.dao.MemberDAO;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import dept.vo.DeptVO;


public class DeptDAO {
	private SqlMapClientTemplate client;
	
	public void setSqlMapClientTemplate(SqlMapClientTemplate client){
		this.client = client;
	}
	
	public void registerDept(HashMap map){
		client.insert("registerDept", map);
	}
	public void deleteDept(String id){
		client.delete("deleteDept", id);
	}
	
	public DeptVO selectDept(String id){
		DeptVO result = (DeptVO) client.queryForObject("selectDept", id);
		System.out.println("[DeptDAO : selectDept] "+result);
		return result;
	}
	
	public List selectAllDept(){
		List<DeptVO> list = (List)client.queryForList("selectAllDept");
		System.out.println("[DeptDAO : selectAllDept] "+list);
		return list;
	}
	public void updateDept(HashMap map){
		client.update("updateDept", map);
	}
	public List selectDeptInfoByCategory(String categoryId) throws SQLException{
		List list = client.queryForList("product.selectProductInfoByCategory", categoryId);
		return list;
	}
	
	public int checkDeptByDeptId(String deptid) {
		int cnt = (Integer) client.queryForObject("checkDeptByDeptId", deptid);
		System.out.println("##### cnt :"+cnt+"  deptid : "+deptid);
		return cnt;
	}	

}